/**
 * 
 */
package com.zcsy.manage.web.tools;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zcsy.commons.tools.highchart.HighChartTool;
import com.zcsy.commons.tools.highchart.model.LineDataInfo;
import com.zcsy.commons.tools.highchart.model.PieDataInfo;
import com.zcsy.commons.tools.highchart.model.PieItemInfo;

/**  
 * @Project: manage
 * @Title: HighChartController.java
 * @Package com.zcsy.manage.web.tools
 * @Description: highchart图标组件接入
 *
 * @author xiangjw 303310059@qq.com
 * @date 2016年3月17日 上午9:24:46
 * @Copyright: 2016 武汉中财数元信息技术有限公司 All rights reserved.
 * @version V1.0  
 */
@Controller
@RequestMapping(value = "/highchart")
public class HighChartController {
	
	
	/** 
	 * @Title: charts 
	 * @Description: 图标组件控制器
	 * @param @param model
	 * @param @param req
	 * @param @return     
	 * @return String     
	 * @throws 
	 */
	@RequestMapping(value="charts" , method = RequestMethod.GET)
	public String charts(Model model, HttpServletRequest req){
		
		//折线图数据封装
		List<LineDataInfo> data = new ArrayList<LineDataInfo>();
		LineDataInfo item_zhang = new LineDataInfo();
		item_zhang.setName("张三");
		List<Float> item_zhang_data = new ArrayList<Float>();
		item_zhang_data.add(50.0f);item_zhang_data.add(580.0f);item_zhang_data.add(350.5f);item_zhang_data.add(100.0f);
		item_zhang.setData(item_zhang_data);
		data.add(item_zhang);
		
		LineDataInfo item_li = new LineDataInfo();
		item_li.setName("李四");
		List<Float> item_li_data = new ArrayList<Float>();
		item_li_data.add(350.2f);item_li_data.add(150.0f);item_li_data.add(50.0f);item_li_data.add(560.5f);
		item_li.setData(item_li_data);
		data.add(item_li);
		
		String line = HighChartTool.getBaseChart(null, "测试折线图"
				, null, null, new String[]{"春" , "夏" , "秋" , "冬"}
				, "销售额", data);
		model.addAttribute("line", line);
		
		//区域图数据封装
		List<LineDataInfo> data_area = new ArrayList<LineDataInfo>();
		LineDataInfo item_hslt = new LineDataInfo();
		item_hslt.setName("hslt");
		List<Float> item_hslt_data = new ArrayList<Float>();
		item_hslt_data.add(0f);item_hslt_data.add(0f);item_hslt_data.add(5f);item_hslt_data.add(10f);
		item_hslt_data.add(50f);item_hslt_data.add(60f);item_hslt_data.add(80f);item_hslt_data.add(70f);
		item_hslt_data.add(60f);item_hslt_data.add(100f);item_hslt_data.add(150f);item_hslt_data.add(150f);
		item_hslt_data.add(180f);item_hslt_data.add(200f);item_hslt_data.add(205f);item_hslt_data.add(210f);
		item_hslt_data.add(180f);item_hslt_data.add(120f);item_hslt_data.add(185f);item_hslt_data.add(170f);
		item_hslt_data.add(250f);item_hslt_data.add(300f);item_hslt_data.add(380f);item_hslt_data.add(600f);
		item_hslt.setData(item_hslt_data);
		data_area.add(item_hslt);
		String area = HighChartTool.getBaseChart(HighChartTool.CHART_AREA,"测试区域图"
				, null, "万元", new String[]{"1991" , "1992" , "1993" , "1994"
						, "1995" , "1996" , "1997" , "1998"
						, "1999" , "2000" , "2001" , "2002"
						, "2003" , "2004" , "2005" , "2006"
						, "2007" , "2008" , "2009" , "2010"
						, "2011" , "2012" , "2013" , "2014"
						, "2015"}
				, "盈利", data_area);
		model.addAttribute("area", area);
		
		//柱状图数据封装
		String column = HighChartTool.getBaseChart(HighChartTool.CHART_COLUMN, "测试柱状图"
				, null, null, new String[]{"春" , "夏" , "秋" , "冬"}
				, "销售额", data);
		model.addAttribute("column", column);
		
		//饼状图数据封装
		List<PieDataInfo> data_pie = new ArrayList<PieDataInfo>();
		PieDataInfo item_pie = new PieDataInfo();
		item_pie.setName("hslt");
		List<PieItemInfo> item_piedata = new ArrayList<PieItemInfo>();
		item_piedata.add(new PieItemInfo("中国", 100f));
		item_piedata.add(new PieItemInfo("美国", 80f));
		item_piedata.add(new PieItemInfo("韩国", 75f));
		item_piedata.add(new PieItemInfo("日本", 10f));
		
		item_pie.setData(item_piedata);
		data_pie.add(item_pie);
		String pie = HighChartTool.getBasePieChart("测试饼状图" , "万亿" , null, data_pie);
		model.addAttribute("pie", pie);
		
		return "tools/highchart/highchart";
	}
	
	
}
